import * as express from "express";
import { wrap } from "../../common/exceptions.js";
import authorizeRequest from "../../middlewares/authorizeRequest.middleware.js";
import ROLE from "../users/role.model.js";
import accountController from "./account.controller.js";

export default express
  .Router()
  .get("/:id", [
    wrap(authorizeRequest([ROLE.ADMIN, ROLE.SUPER_ADMIN])),
    wrap(accountController.byId),
  ])
  .put("/:id", [
    wrap(authorizeRequest([ROLE.ADMIN, ROLE.SUPER_ADMIN])),
    wrap(accountController.update),
  ])
  // New endpoint for setting trial periods - restricted to SUPER_ADMIN only
  .put("/:id/trial", [
    wrap(authorizeRequest([ROLE.SUPER_ADMIN])),
    wrap(accountController.setTrialPeriod),
  ]);